package model.admin;

import java.sql.SQLException;
import java.util.List;

import model.admin.ListVO;
import model.admin.PagingBean;
import model.member.MemberVO;



public class AdminService {
private AdminDao adminDao;
public AdminService(AdminDao adminDao){
	this.adminDao=adminDao;
}
public List<NoticeBoardVO> noticeBoardList() throws SQLException{
	return adminDao.noticeBoardList();
}
public void writeNotice(NoticeBoardVO nvo) throws SQLException {
	int no= adminDao.writeNotice(nvo);
	nvo.setNoticeNO(no);
	
	
}
public void deleteNoticeBoard(int no) throws SQLException {
	adminDao.deleteNoticeBoard(no);
	
}
public void updateNoticeBoardContent(NoticeBoardVO nvo) throws SQLException{
	adminDao.updateNoticeBoardContent(nvo);
}
public NoticeBoardVO getContent(NoticeBoardVO nvo) throws SQLException {
	return adminDao.getContent(nvo);
}
public NoticeBoardVO getNotice(NoticeBoardVO nvo) throws SQLException{
	adminDao.updateNoticeCount(nvo);
	return adminDao.getNotice(nvo);
}

public ListVO allMember(String pageNo) throws SQLException{
	if(pageNo==null||pageNo==""){
		pageNo="1";
	}
	List<MemberVO> list=adminDao.allMember(pageNo);
	int totalContent=adminDao.getTotalMember();
	ListVO listVO=new ListVO(list,new PagingBean(totalContent, Integer.parseInt(pageNo)));
	return listVO;
}
public MemberVO findMemberById(MemberVO mvo) throws SQLException {
	return adminDao.findMemberById(mvo);
}
public void updateUserLevel(MemberVO mvo) throws SQLException {
	adminDao.updateUserLevel(mvo);
}
//멤버 강제 탈퇴 member의 deleteMember로 대체됨
/*public void removeMember(MemberVO mvo) throws SQLException {
	adminDao.removeMember(mvo);
}*/

public NoticeListVO getNoticeList(String pageNo) throws SQLException {
	if(pageNo==null||pageNo==""){
		pageNo="1";
	}
	List<NoticeBoardVO> list=adminDao.noticeList(pageNo);
	int totalContent=adminDao.getTotalNotice();
	NoticeListVO noticeListVO=new NoticeListVO(list,new PagingBean(totalContent, Integer.parseInt(pageNo)));
	return noticeListVO;
}
public MemberVO idExist(String id) throws SQLException {
	return adminDao.idExist(id);
}
public void optionalServiceRequest(OptionalServiceVO osvo) throws SQLException {
	 adminDao.optionalServiceRequest(osvo);
	
}
public OptionalServiceVO requestChecked(MemberVO mvo) throws SQLException {
	return adminDao.requestChecked(mvo);
}
public void requestM(String id) throws SQLException {
	OptionalServiceVO osvo=new OptionalServiceVO();
	int optionalNo=adminDao.requestNoById(id);
	osvo.setOptionalNo(optionalNo);
	osvo.setmId(id);
	adminDao.requestM(osvo);
}

public void requestW(String id) throws SQLException {
	OptionalServiceVO osvo=new OptionalServiceVO();
	int optionalNo=adminDao.requestNoById(id);
	osvo.setOptionalNo(optionalNo);
	osvo.setmId(id);
	adminDao.requestW(osvo);
}

public boolean duplicationServiceId(String id) throws SQLException {
	boolean flag=false;
	if(adminDao.duplicationServiceId(id)){
		flag=true;
	}
	return flag;
	}
public List<OptionalServiceVO> requestManagement() throws SQLException {
	return adminDao.requestManagement();
}
public OptionalServiceVO requestConfirm(OptionalServiceVO osvo) throws SQLException {
	return adminDao.requestConfirm(osvo);
}
public void adminAllow(OptionalServiceVO osvo) throws SQLException {
	adminDao.adminAllow(osvo);
}
}
